package com.um.springboot.starter.configuration;

import cn.hutool.core.util.StrUtil;
import org.redisson.spring.starter.RedissonAutoConfiguration;
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 甘天伟
 * @since 2024/5/7
 * 版权所有 广州优匠科技有限公司
 */
@Configuration
@ConditionalOnClass(RedissonAutoConfiguration.class)
public class RedissonConfiguration {

    @Bean
    public RedissonAutoConfigurationCustomizer redissonAutoConfigurationCustomizer() {
        return configuration -> {
            // 修复密码为空时Redisson会报错的问题
            if (StrUtil.isBlank(configuration.useSingleServer().getPassword())) {
                configuration.useSingleServer().setPassword(null);
            }
        };
    }
}
